<template>
  <div class="chart"></div>
</template>
  
  <script>
import * as echarts from "echarts";

export default {
  name: "datapanel",
  data() {
    return {
      chart: null,
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart();
    });
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
  methods: {
    initChart() {
      //初始化图表
      this.chart = echarts.init(this.$el);
      //设置图表
      this.chart.setOption({
        tooltip: {
          formatter: "{a} <br/>{b} : {c}%",
        },
        series: [
          {
            name: "Pressure",
            type: "gauge",
            progress: {
              show: true,
            },
            detail: {
              valueAnimation: true,
              formatter: "{value}",
            },
            data: [
              {
                value: 30,
                name: "车次",
              },
            ],
          },
        ],
      });
    },
  },
};
</script>
<style scoped>
.chart {
  width: 500px;
  height: 450px;
}
</style>
  